package com.a16.yuejian.yuejian.activity;

import android.content.Context;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import android.view.View;
import android.widget.ImageView;

import com.a16.yuejian.yuejian.R;
import com.a16.yuejian.yuejian.adapter.MyFollowAdapter;
import com.a16.yuejian.yuejian.javabean.Follow;
import com.a16.yuejian.yuejian.listener.Listener;
import com.a16.yuejian.yuejian.model.MyPersonalModel;

import java.util.List;

public class MyFollowActivity extends AppCompatActivity implements View.OnClickListener {
    private RecyclerView recyclerview;
    private ImageView my_follow_back;
    private SharedPreferences sp;

    Listener<List<Follow>> listListener = new Listener<List<Follow>>() {
        @Override
        public void onResponse(List<List<Follow>> t) {
            recyclerview.setAdapter(new MyFollowAdapter(MyFollowActivity.this,t));
        }

        @Override
        public void onFail() {

        }
    };




    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_my_follow);
        initView();
        initEvent();
        getData();
    }

    public void getData() {
        MyPersonalModel myPersonalModel = new MyPersonalModel();
        myPersonalModel.allfollow(sp.getString("uid",""),listListener);
    }

    private void initEvent() {
        my_follow_back.setOnClickListener(this);
    }

    private void initView() {
        my_follow_back = (ImageView)findViewById(R.id.my_follow_back);
        recyclerview = (RecyclerView)findViewById(R.id.rv_myfollow);
        recyclerview.setLayoutManager(new LinearLayoutManager(MyFollowActivity.this));
        sp = getSharedPreferences("userinfo", Context.MODE_PRIVATE);
    }

    @Override
    public void onClick(View v) {
        switch (v.getId()){
            case R.id.my_follow_back:
                finish();
                break;
        }
    }
}
